package com.example.sharesinfo.fragment.stock;


import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.nfc.Tag;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.sharesinfo.R;
import com.example.sharesinfo.adapter.CommonAdapter;
import com.example.sharesinfo.adapter.CommonViewHolder;
import com.example.sharesinfo.bean.HuShenMarkeBean;
import com.example.sharesinfo.bean.HuShenRankingBean;

import com.example.sharesinfo.model.HuShenRankingModel;
import com.example.sharesinfo.ui.SharesInfoActivity;
import com.example.sharesinfo.utils.CommonUtils;
import com.example.sharesinfo.utils.LogUtils;
import com.example.sharesinfo.utils.OkHttpUtils;
import com.example.sharesinfo.view.CustomRadioGroup;
import com.example.sharesinfo.view.TextBannerView;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * A simple {@link Fragment} subclass.
 */
public class MarketHuShenFragment extends Fragment implements RadioGroup.OnCheckedChangeListener {
    /**
     * 问题：现有价格：result.getData().get(i).getNowPrice();显示增加减少多少而不是现有价值
     * 市场概况：UI和接口返回数据不一致
     * A股沪深 股票排行（行情->A股->股票排行 一栏数据）ui未做、
     * 先请求存储 空间换时间？
     */
    private String LogTag = "MarketHuShenFragment:";
    private static final int GetAShareStatusSuccess = 1001;
    private static final int GetAShareStatusFailed = 1002;
    private TextBannerView dataBanner;
    private List<String> dataList = new ArrayList<>();

    //上证指数
    private FrameLayout SZ_FL;
    private TextView SZ_Name;
    private TextView SZ_Now_Price;
    private TextView SZ_Diff_Rate;
    private TextView SZ_Diff_Money;
    //深圳指数
    private FrameLayout SHZ_FL;
    private TextView SHZ_Name;
    private TextView SHZ_Now_Price;
    private TextView SHZ_Diff_Rate;
    private TextView SHZ_Diff_Money;
    //创业指数
    private FrameLayout CY_FL;
    private TextView CY_Name;
    private TextView CY_Now_Price;
    private TextView CY_Diff_Rate;
    private TextView CY_Diff_Money;
    private int temp;//用来标识上面三个

    //
    private TextView tv_front;
    private TextView tv_behind;
    //
    private TextView tv_performance;

    //A股沪深 股票排行（行情->A股->股票排行 一栏数据）
    private RecyclerView mView;
    private CommonAdapter<HuShenRankingModel> mRankAdapter;
    private List<HuShenRankingModel> mList = new ArrayList<>();
    private RadioButton rank_positive;
    private RadioButton rank_reverse;
    private CustomRadioGroup rank_type;
    private int usedp = 0;//来处理RadioGroup回调二次,类似于互斥
    private int usedr = 0;
    private int useda = 0;
    private int usedb = 0;
    private int usedc = 0;
    private int usedd = 0;
    private int usede = 0;
    private int usedf = 0;
    // A股 沪深 热点板块（行情->A股->沪深->热点板块 一栏数据）
    private TextView tv_name1;
    private TextView tv_name2;
    private TextView tv_name3;
    private TextView tv_name4;
    private TextView tv_name5;
    private TextView tv_data1;
    private TextView tv_data2;
    private TextView tv_data3;
    private TextView tv_data4;
    private TextView tv_data5;
    private List<JSONObject> HotPlate = new ArrayList<>();
    private RadioGroup HotPlate_Type;
    private int type1 = 0;
    private int type2 = 0;
    private int type3 = 0;
    //左上角状态
    private TextView hu_shen_state;
    private TextView hu_shen_date;
    //
    private TextView hu_shen_stocks_ranking_selection;
    private Handler mHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            switch (msg.what) {
                case 200:
                    HuShenMarkeBean result = (HuShenMarkeBean) msg.obj;
                    for (int i = 0; i < result.getData().size(); i++) {
                        if (result.getData().get(i).getDiff_Rate() == null) {
                            String NowPrise = result.getData().get(i).getNowPrice();
                            NowPrise = NowPrise.replace("亿", "");
                            dataList.add(stockData(Double.parseDouble(NowPrise))
                                    + result.getData().get(i).getName());
                        } else {
                            switch (temp) {
                                case 0:
                                    temp += 1;
                                    SZ_Name.setText(result.getData().get(i).getName());
                                    SZ_Now_Price.setText(result.getData().get(i).getNowPrice());
                                    SZ_Diff_Rate.setText(result.getData().get(i).getDiff_Money() + "%");
                                    SZ_Diff_Money.setText(result.getData().get(i).getDiff_Rate());

                                    if (Double.parseDouble(result.getData().get(i).getDiff_Rate()) > 0) {
                                        SZ_FL.setBackground(getResources().getDrawable(R.drawable.red_gradient_background));
                                        SZ_Now_Price.setTextColor(getResources().getColor(R.color.red));
                                        SZ_Diff_Money.setTextColor(getResources().getColor(R.color.red));
                                        SZ_Diff_Rate.setTextColor(getResources().getColor(R.color.red));
                                    } else {
                                        SZ_FL.setBackground(getResources().getDrawable(R.drawable.green_gradient_background));
                                        SZ_Now_Price.setTextColor(getResources().getColor(R.color.green));
                                        SZ_Diff_Money.setTextColor(getResources().getColor(R.color.green));
                                        SZ_Diff_Rate.setTextColor(getResources().getColor(R.color.green));
                                    }

                                    break;
                                case 1:
                                    temp += 1;
                                    SHZ_Name.setText(result.getData().get(i).getName());
                                    SHZ_Now_Price.setText(result.getData().get(i).getNowPrice());
                                    SHZ_Diff_Rate.setText(result.getData().get(i).getDiff_Money() + "%");
                                    SHZ_Diff_Money.setText(result.getData().get(i).getDiff_Rate());

                                    if (Double.parseDouble(result.getData().get(i).getDiff_Rate()) > 0) {
                                        SHZ_FL.setBackground(getResources().getDrawable(R.drawable.red_gradient_background));
                                        SHZ_Now_Price.setTextColor(getResources().getColor(R.color.red));
                                        SHZ_Diff_Money.setTextColor(getResources().getColor(R.color.red));
                                        SHZ_Diff_Rate.setTextColor(getResources().getColor(R.color.red));
                                    } else {
                                        SHZ_FL.setBackground(getResources().getDrawable(R.drawable.green_gradient_background));
                                        SHZ_Now_Price.setTextColor(getResources().getColor(R.color.green));
                                        SHZ_Diff_Money.setTextColor(getResources().getColor(R.color.green));
                                        SHZ_Diff_Rate.setTextColor(getResources().getColor(R.color.green));
                                    }
                                    break;
                                case 2:
                                    temp += 1;
                                    CY_Name.setText(result.getData().get(i).getName());
                                    CY_Now_Price.setText(result.getData().get(i).getNowPrice());
                                    CY_Diff_Rate.setText(result.getData().get(i).getDiff_Money() + "%");
                                    CY_Diff_Money.setText(result.getData().get(i).getDiff_Rate());

                                    if (Double.parseDouble(result.getData().get(i).getDiff_Rate()) > 0) {
                                        CY_FL.setBackground(getResources().getDrawable(R.drawable.red_gradient_background));
                                        CY_Now_Price.setTextColor(getResources().getColor(R.color.red));
                                        CY_Diff_Money.setTextColor(getResources().getColor(R.color.red));
                                        CY_Diff_Rate.setTextColor(getResources().getColor(R.color.red));
                                    } else {
                                        CY_FL.setBackground(getResources().getDrawable(R.drawable.green_gradient_background));
                                        CY_Now_Price.setTextColor(getResources().getColor(R.color.green));
                                        CY_Diff_Money.setTextColor(getResources().getColor(R.color.green));
                                        CY_Diff_Rate.setTextColor(getResources().getColor(R.color.green));
                                    }
                                    break;
                            }
                        }
                    }
                    dataBanner.setDatas(dataList);
                    break;
                case 201:
                    JSONObject result1 = (JSONObject) msg.obj;
                    try {
                        String percent = result1.getString("涨跌停对比");
                        String[] list = percent.split(":");
                        tv_front.setText(list[1]);
                        tv_behind.setText(list[0]);
                        tv_performance.setText(result1.getString("昨日涨停表现"));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    break;
                case 202:
                    if (mList.size() > 0) {
                        mList.clear();
                    }
                    HuShenRankingBean result2 = (HuShenRankingBean) msg.obj;
                    int top10 = 0;
                    if (CommonUtils.isEmpty(result2.getData())) {
                        for (int i = 0; i < result2.getData().size(); i++) {
                            if (top10 == 10) {
                                break;
                            }
                            HuShenRankingModel model = new HuShenRankingModel();
                            model.setName(result2.getData().get(i).getName());
                            model.setCode(result2.getData().get(i).getCode());
                            model.setNowPrice(result2.getData().get(i).getNowPrice());
                            model.setSortField(result2.getData().get(i).getSortField());
                            if (result2.getData().get(i).getStockIndustry() == null) {
                                result2.getData().get(i).setStockIndustry("");
                            }
                            model.setStockIndustry(result2.getData().get(i).getStockIndustry());
                            mList.add(model);
                            top10 += 1;
                        }
                        mRankAdapter.notifyDataSetChanged();
                    }
                    break;
                case 203:
                    if (HotPlate.size() > 0) {
                        HotPlate.clear();
                    }
                    JSONArray result3 = (JSONArray) msg.obj;
                    try {
                        LogUtils.i(LogTag + result3.get(0));
                        for (int i = 0; i < result3.length(); i++) {
                            JSONObject object = (JSONObject) result3.get(i);
                            HotPlate.add(object);
                        }
                        LogUtils.i(LogTag + "长度：" + HotPlate.size());
                        putHotPlateData(0);

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    break;
                case GetAShareStatusSuccess:
                    JSONObject result4 = (JSONObject) msg.obj;
                    try {
                        hu_shen_state.setText(result4.getString("status"));
                        hu_shen_date.setText(result4.getString("date"));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    break;
                case GetAShareStatusFailed:
                    break;
                case 404:
                    break;
                case 405:
                    break;
                case 406:
                    break;
                case 407:
                    break;
            }
            return false;
        }
    });

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_market_hu_shen, null);
        initView(view);
        initData();
        queryDatas();
        getAShareStatus();

        return view;
    }

    private void initView(View view) {
        hu_shen_stocks_ranking_selection = view.findViewById(R.id.hu_shen_stocks_ranking_selection);
        hu_shen_state = view.findViewById(R.id.hu_shen_state);
        hu_shen_date = view.findViewById(R.id.hu_shen_date);

        dataBanner = view.findViewById(R.id.hu_shen_data_banner);
        mView = view.findViewById(R.id.mHu_Shen_View);
        mView.setLayoutManager(new LinearLayoutManager(getActivity()));
        mView.addItemDecoration(new DividerItemDecoration(getActivity(),
                DividerItemDecoration.VERTICAL));
        SZ_FL = view.findViewById(R.id.hu_shen_shang_data_background);
        SZ_FL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharesInfoActivity.startActivity(getContext(), "000001");
            }
        });
        SZ_Name = view.findViewById(R.id.hu_shang_zheng_name);
        SZ_Now_Price = view.findViewById(R.id.hu_shang_zheng_data_1);
        SZ_Diff_Money = view.findViewById(R.id.hu_shang_zheng_data_2);
        SZ_Diff_Rate = view.findViewById(R.id.hu_shang_zheng_data_3);

        SHZ_FL = view.findViewById(R.id.hu_shen_sheng_data_background);
        SHZ_FL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharesInfoActivity.startActivity(getContext(), "399001");
            }
        });
        SHZ_Name = view.findViewById(R.id.hu_shen_sheng_name);
        SHZ_Now_Price = view.findViewById(R.id.hu_shen_sheng_data_1);
        SHZ_Diff_Money = view.findViewById(R.id.hu_shen_sheng_data_2);
        SHZ_Diff_Rate = view.findViewById(R.id.hu_shen_sheng_data_3);

        CY_FL = view.findViewById(R.id.hu_shen_chuang_ye_data_background);
        CY_FL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharesInfoActivity.startActivity(getContext(), "399006");
            }
        });
        CY_Name = view.findViewById(R.id.hu_shen_chuang_ye_name);
        CY_Now_Price = view.findViewById(R.id.hu_shen_chuang_ye_data_1);
        CY_Diff_Money = view.findViewById(R.id.hu_shen_chuang_ye_data_2);
        CY_Diff_Rate = view.findViewById(R.id.hu_shen_chuang_ye_data_3);

        tv_front = view.findViewById(R.id.tv_front);
        tv_behind = view.findViewById(R.id.tv_behind);
        tv_performance = view.findViewById(R.id.tv_performance);
        rank_type = view.findViewById(R.id.hu_shen_stocks_ranking_radio_group);
        rank_type.setOnCheckedChangeListener(this);
        mRankAdapter = new CommonAdapter<>(mList, new CommonAdapter.OnBindDataListener<HuShenRankingModel>() {
            @Override
            public void onBindViewHolder(final HuShenRankingModel model, CommonViewHolder viewHolder, int type, int position) {
                viewHolder.setText(R.id.hu_shen_stocks_ranking_list_name, model.getName());
                viewHolder.setText(R.id.hu_shen_stocks_ranking_list_id, model.getCode());
                viewHolder.setText(R.id.hu_shen_stocks_ranking_list_newest, model.getNowPrice());
                viewHolder.setText(R.id.hu_shen_stocks_ranking_list_selection, model.getSortField());
                TextView newest = viewHolder.getView(R.id.hu_shen_stocks_ranking_list_newest);
                TextView selection = viewHolder.getView(R.id.hu_shen_stocks_ranking_list_selection);
                CommonUtils.setTextColor(newest, model.getNowPrice());
                CommonUtils.setTextColor(selection, model.getSortField());

                viewHolder.setText(R.id.hu_shen_stocks_ranking_list_industry_groups, model.getStockIndustry());
                viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        SharesInfoActivity.startActivity(getContext(), model.getCode());
                    }
                });
            }

            @Override
            public int getLayoutId(int type) {
                return R.layout.hu_shen_stocks_item;
            }
        });
        mView.setAdapter(mRankAdapter);
        // A股 沪深 热点板块（行情->A股->沪深->热点板块 一栏数据）
        tv_name1 = view.findViewById(R.id.tv_hot1_name);
        tv_name2 = view.findViewById(R.id.tv_hot2_name);
        tv_name3 = view.findViewById(R.id.tv_hot3_name);
        tv_name4 = view.findViewById(R.id.tv_hot4_name);
        tv_name5 = view.findViewById(R.id.tv_hot5_name);
        tv_data1 = view.findViewById(R.id.tv_hot1_data);
        tv_data2 = view.findViewById(R.id.tv_hot2_data);
        tv_data3 = view.findViewById(R.id.tv_hot3_data);
        tv_data4 = view.findViewById(R.id.tv_hot4_data);
        tv_data5 = view.findViewById(R.id.tv_hot5_data);

        HotPlate_Type = view.findViewById(R.id.hu_shen_hot_plate_radio_group);
        HotPlate_Type.setOnCheckedChangeListener(this);

    }

    private void initData() {
        temp = 0;
    }

    private void queryRank(String SortField, String SortType) {

        // A股沪深 股票排行（行情->A股->股票排行 一栏数据）
        final String url = "http://119.23.221.142/api/stock/GetStocksRankingBrief?SortField=" +
                SortField + "&SortType=" + SortType + "&Page=1";
        OkHttpUtils.getInstance().Get(url, new OkHttpUtils.okHttpListener() {
            Message message = mHandler.obtainMessage();

            @Override
            public void OnSuccess(String s, int code) throws JSONException {
                LogUtils.i(LogTag + url + s);
                HuShenRankingBean bean = new Gson().fromJson(s, HuShenRankingBean.class);
                message.what = 202;
                message.obj = bean;
                mHandler.sendMessage(message);
            }

            @Override
            public void OnFailed(String s) {
                message.what = 406;
                message.obj = s;
                mHandler.sendMessage(message);
            }
        });
    }

    private void getAShareStatus() {

        //  A股=》沪深  左上角的数据
        String url = " http://119.23.221.142/api/stock/GetAShareStatus";
        OkHttpUtils.getInstance().Get(url, new OkHttpUtils.okHttpListener() {
            Message message = mHandler.obtainMessage();

            @Override
            public void OnSuccess(String s, int code) throws JSONException {
                JSONObject object = new JSONObject(s);
                if (object.getString("code").equals("200")) {
                    message.what = GetAShareStatusSuccess;
                    message.obj = object;
                    mHandler.sendMessage(message);
                } else {
                    message.what = GetAShareStatusFailed;
                    mHandler.sendMessage(message);
                }

            }

            @Override
            public void OnFailed(String s) {
                message.what = 404;
                message.obj = s;
                mHandler.sendMessage(message);
            }
        });
    }

    private void queryDatas() {
        //A股沪深（行情->A股->沪深界面中，右上角的轮播图以及三个指数（上证指数、深证成指、创业板）数据
        OkHttpUtils.getInstance().Get("http://119.23.221.142/api/stock/GetAShareHuShenMarketIndex"
                , new OkHttpUtils.okHttpListener() {
                    Message message = mHandler.obtainMessage();

                    @Override
                    public void OnSuccess(String s, int code) throws JSONException {
                        HuShenMarkeBean bean = new Gson().fromJson(s, HuShenMarkeBean.class);
                        message.what = code;
                        message.obj = bean;
                        mHandler.sendMessage(message);
                    }

                    @Override
                    public void OnFailed(String s) {
                        message.what = 404;
                        message.obj = s;
                        mHandler.sendMessage(message);
                    }

                });
        //A股沪深 市场概况（行情->A股->沪深 市场概况一栏的数据）
        OkHttpUtils.getInstance().Get("http://119.23.221.142/api/stock/GetMarketOverview", new OkHttpUtils.okHttpListener() {
            Message message = mHandler.obtainMessage();

            @Override
            public void OnSuccess(String s, int code) throws JSONException {

                JSONObject response = new JSONObject(s);
                JSONObject result = new JSONObject(response.getString("data"));
                message.what = 201;
                message.obj = result;
                LogUtils.i(LogTag + result.getString("涨股数"));
                mHandler.sendMessage(message);
            }

            @Override
            public void OnFailed(String s) {
                message.what = 405;
                message.obj = s;
                mHandler.sendMessage(message);
            }
        });

        queryRank("diff_rate", "-1");

        // A股 沪深 热点板块（行情->A股->沪深->热点板块 一栏数据） 无参数 Get
        OkHttpUtils.getInstance().Get("http://119.23.221.142/api/stock/GetHotPlateTop5", new OkHttpUtils.okHttpListener() {
            Message message = mHandler.obtainMessage();

            @Override
            public void OnSuccess(String s, int code) throws JSONException {
                LogUtils.i(LogTag + s);
                JSONObject response = new JSONObject(s);
                JSONArray array = response.getJSONArray("data");
                LogUtils.i(LogTag + array.length());
                message.what = 203;
                message.obj = array;
                mHandler.sendMessage(message);

            }

            @Override
            public void OnFailed(String s) {
                message.what = 407;
                message.obj = s;
                mHandler.sendMessage(message);
            }
        });
    }

    private String stockData(double data) {
        String str = null;
        if (data > 0)
            str = "<font color='#ED382B'><big>+" + data + "亿</big></font><br/>";
        else
            str = "<font color='#169619'><big>" + data + "亿</big></font><br/>";
        return str;
    }

    private String[] ParseHotPlate(String datas) {
        datas = datas.replace("\"", "");
        datas = datas.replace("{", "");
        datas = datas.replace("}", "");
        return datas.split(":");
    }

    private void putHotPlateData(int index) {
        JSONArray list = new JSONArray();
        switch (index) {
            case 0:
                try {
                    list = HotPlate.get(0).getJSONArray("今日涨幅最大");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                break;
            case 1:
                try {
                    list = HotPlate.get(1).getJSONArray("资金流入最多");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                break;
            case 2:
                try {
                    list = HotPlate.get(2).getJSONArray("5日涨幅最大");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                break;
        }
        try {
            LogUtils.i(LogTag + "putHotPlateData" + list.get(0));
            String data = list.get(0).toString();
            String[] datas = ParseHotPlate(data);
            tv_name1.setText(datas[0]);
            tv_data1.setText(datas[1]);

            data = list.get(1).toString();
            datas = ParseHotPlate(data);
            tv_name2.setText(datas[0]);
            tv_data2.setText(datas[1]);

            data = list.get(2).toString();
            datas = ParseHotPlate(data);
            tv_name3.setText(datas[0]);
            tv_data3.setText(datas[1]);

            data = list.get(3).toString();
            datas = ParseHotPlate(data);
            tv_name4.setText(datas[0]);
            tv_data4.setText(datas[1]);

            data = list.get(4).toString();
            datas = ParseHotPlate(data);
            tv_name5.setText(datas[0]);
            tv_data5.setText(datas[1]);

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.hu_shen_stocks_ranking_rb_1:
                if (usedp == 0) {
                    hu_shen_stocks_ranking_selection.setText("涨幅");
                    LogUtils.i(LogTag + "正序");
                    queryRank("diff_rate", "-1");
                    usedp = 1;
                    usedr = 0;
                    useda = 0;
                    usedb = 0;
                    usedc = 0;
                    usedd = 0;
                    usede = 0;
                    usedf = 0;
                }
                break;
            case R.id.hu_shen_stocks_ranking_rb_2:
                if (usedr == 0) {
                    hu_shen_stocks_ranking_selection.setText("跌幅");
                    LogUtils.i(LogTag + "倒序");
                    queryRank("diff_rate", "1");
                    usedp = 0;
                    usedr = 1;
                    useda = 0;
                    usedb = 0;
                    usedc = 0;
                    usedd = 0;
                    usede = 0;
                    usedf = 0;
                }
                break;
            case R.id.hu_shen_stocks_ranking_rb_3:
                //当前价
                if (useda == 0) {
                    hu_shen_stocks_ranking_selection.setText("当前价");
                    queryRank("nowPrice", "-1");
                    usedp = 0;
                    usedr = 0;
                    useda = 1;
                    usedb = 0;
                    usedc = 0;
                    usedd = 0;
                    usede = 0;
                    usedf = 0;
                }
                break;
            case R.id.hu_shen_stocks_ranking_rb_4:
                //换手率
                if (usedb == 0) {
                    hu_shen_stocks_ranking_selection.setText("换手率");
                    queryRank("turnover", "-1");
                    usedp = 0;
                    usedr = 0;
                    useda = 0;
                    usedb = 1;
                    usedc = 0;
                    usedd = 0;
                    usede = 0;
                    usedf = 0;
                }
                break;
            case R.id.hu_shen_stocks_ranking_rb_5:
                //开盘价
                if (usedc == 0) {
                    hu_shen_stocks_ranking_selection.setText("开盘价");
                    queryRank("openPrice", "-1");
                    usedp = 0;
                    usedr = 0;
                    useda = 0;
                    usedb = 0;
                    usedc = 1;
                    usedd = 0;
                    usede = 0;
                    usedf = 0;
                }
                break;
            case R.id.hu_shen_stocks_ranking_rb_6:
                //收盘价
                if (usedd == 0) {
                    hu_shen_stocks_ranking_selection.setText("收盘价");
                    queryRank("closePrice", "-1");
                    usedp = 0;
                    usedr = 0;
                    useda = 0;
                    usedb = 0;
                    usedc = 0;
                    usedd = 1;
                    usede = 0;
                    usedf = 0;
                }
                break;
            case R.id.hu_shen_stocks_ranking_rb_7:
                //成交量
                if (usede == 0) {
                    hu_shen_stocks_ranking_selection.setText("成交量");
                    queryRank("tradeAmount", "-1");
                    usedp = 0;
                    usedr = 0;
                    useda = 0;
                    usedb = 0;
                    usedc = 0;
                    usedd = 0;
                    usede = 1;
                    usedf = 0;
                }
                break;
            case R.id.hu_shen_stocks_ranking_rb_8:
                //交易量
                if (usedf == 0) {
                    hu_shen_stocks_ranking_selection.setText("交易量");
                    queryRank("tradeNum", "-1");
                    usedp = 0;
                    usedr = 0;
                    useda = 0;
                    usedb = 0;
                    usedc = 0;
                    usedd = 0;
                    usede = 0;
                    usedf = 1;
                }
                break;
            case R.id.hu_shen_hot_plate_rb_1:
                if (type1 == 0) {
                    LogUtils.i(LogTag + "RB" + "今日涨幅最大");
                    putHotPlateData(0);
                    type1 = 1;
                    type2 = 0;
                    type3 = 0;
                }
                break;
            case R.id.hu_shen_hot_plate_rb_2:
                if (type2 == 0) {
                    LogUtils.i(LogTag + "RB" + "流入资金最多");
                    putHotPlateData(1);
                    type1 = 0;
                    type2 = 1;
                    type3 = 0;
                }
                break;
            case R.id.hu_shen_hot_plate_rb_3:
                if (type3 == 0) {
                    LogUtils.i(LogTag + "RB" + "5日涨幅最大");
                    putHotPlateData(2);
                    type1 = 0;
                    type2 = 0;
                    type3 = 1;
                }
                break;

        }
    }
}
